//index

define("index",["jquery","qrouter"],function($,qrouter){
    var index={
        init:function(){
            var indexhtml = {
                htmlindex : $(".iframeindex").html(),
                htmlback : $("body").css('background')
            }
            var routerarr = [
                '#!work/gongdan','#!work/wode','#!work/chaxun',
                '#!gongdan/gl','#!gongdan/wt','#!gongdan/bg','#!gongdan/fb','#!gongdan/pz',
                '#!fuwu/gz','#!fuwu/fw',
                '#!age/gr'
            ];
            function attrindex(obj){
                obj.each(function(index,item){
                    $(item).attr({
                        href : routerarr[index]
                    })
                })
            }
            function background(){$("body").css('background','#fff');}
     
            Q.reg('index',function(){
                $(".iframeindex").html(indexhtml.htmlindex).parents('body').css('background',indexhtml.htmlback);
                attrindex($(".concdd a"));
            }).reg([
                ['work',function(str){
                    require(['requireText!workhtml','requireCss!workcss','work'],function(html,css,js){
                        $(".iframeindex").html(html);
                        js.init();
                        background();
                        require(['requireCss!workjdcss'],function(css){
                            $("head").append(css);
                            // js.init();
                        });
                    });
                    if(str === 'gongdan'){
                        // console.log(str);
                        require(['requireText!workjd','requireCss!workjdcss'],function(html,css){
                            $(".formdivbox").html(html);
                            // js.init();
                        });
                    }else if(str === 'wode'){
                        require(['requireText!workwd','requireCss!workcss'],function(html,css){
                            $(".formdivbox").html(html);
                            // js.init();
                            // background();
                        });
                    }else if(str === 'chaxun'){
                        require(['requireText!workcx','requireCss!workcxcss'],function(html,css){
                            $(".formdivbox").html(html);
                            // js.init();
                        });
                    }
                }],
                ['gongdan',function(str){
                    require(['requireText!gongdanhtml','requireCss!gongdancss','gongdan'],function(html,css,js){
                        $(".iframeindex").html(html);
                        js.init();
                        background();
                        require(['requireCss!gongdangzcss'],function(css){
                            $("head").append(css);
                            // js.init();
                        });
                    });
                    switch(str){
                        case 'gl':
                        require(['requireText!gongdangzhtml','requireCss!gongdangzcss'],function(html,css){
                            $(".formdivbox").html(html);
                            // js.init();
                        });
                        break;
                        case 'wt':
                        require(['requireText!gongdangzhtml','requireCss!gongdangzcss'],function(html,css){
                            $(".formdivbox").html(html);
                            // js.init();
                        });
                        break;
                        case 'bg':
                        require(['requireText!gongdangzhtml','requireCss!gongdangzcss'],function(html,css){
                            $(".formdivbox").html(html);
                            // js.init();
                        });
                        break;
                        case 'fb':
                        require(['requireText!gongdangzhtml','requireCss!gongdangzcss'],function(html,css){
                            $(".formdivbox").html(html);
                            // js.init();
                        });
                        break;
                        case 'pz':
                        require(['requireText!gongdangzhtml','requireCss!gongdangzcss'],function(html,css){
                            $(".formdivbox").html(html);
                            // js.init();
                        });
                        break;
                        default:break;
                    }
                
                }],
                ['fuwu',function(str){
                    require(['requireText!fuwuzhilianghtml','requireCss!fuwuzhiliangcss','fuwuzhiliang','fuwuguzhang'],function(html,css,js1,js2){
                        $(".iframeindex").html(html);
                        js1.init();
                        background();
                        js2.init();
                        // require(['fuwuguzhang'],function(js){
                        //     // $("head").append(css);
                        //     js.init();
                        // });
                    });
                    if(str === 'gz'){
                        // console.log(str);
                        require(['requireText!fuwuguzhanghtml','requireCss!fuwuzhiliangcss','fuwuguzhang'],function(html,css,js){
                            $(".formdivbox").html(html);
                            js.init();
                        });
                    }else if(str === 'fw'){
                        require(['requireText!fuwuguzhang2html','fuwuguzhang2'],function(html,js){
                            $(".formdivbox").html(html);
                            js.init();
                        });
                    }
                   
                }],
                ['age',function(){
                    require(['requireText!ageshtml','requireCss!agescss','ages'],function(html,css,js){
                        $(".iframeindex").html(html);
                        js.init();
                        background();
                    });
                }],
            ])
             
            Q.init({
                index:'index', /* 首页 */
                pop:navchange=function(L){
                    /* 每次有url变更时都会触发pop回调 */
                    var a=$('.healeftbox dl a[href="#!'+L+'"]');
                    $(a).addClass('heaactive').siblings().removeClass("heaactive");
                    // console.log(window.location.hash)
                    if(window.location.hash == '#!index'){
                        $('.heaactive').removeClass("heaactive");
                    }
                } 
            });
             
            
            

        },

    };
    return index;

});









